/**
 *  Copyright (C) 2010  Thomas Volk
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package com.googlecode.bookmarks.core.beans;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@NamedQueries(value={
	@NamedQuery(
		name="findMimeTypeByTypes",
		query="select object(m) from MimeType m " +
				"where m.type=:type and m.subType=:subType"
	)
})
@Table(uniqueConstraints={
	@UniqueConstraint(columnNames={"type", "subType"})
})
@Entity
public class MimeType {
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
	@Column(length=255, nullable=false)
	private String type;
	@Column(length=255, nullable=false)
    private String subType;
    
	public MimeType() {
	}

	public MimeType(String type, String subType) {
		this.type = type;
		this.subType = subType;
	}

	public MimeType(String mimeTypes) {
		String[] types = mimeTypes.split("/");
		this.type = types[0];
		this.subType = types[1];
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getSubType() {
		return subType;
	}

	public void setSubType(String subType) {
		this.subType = subType;
	}
    
    
}
